// Platform independent LCD panel interface
#ifndef __LCDCONTROLLER_H__
#define __LCDCONTROLLER_H__

#include "windows.h"

/* Frame buffer contains a pointer to the memory region which holds the
 * palette and the pixel data. The palette and pixel data are dependent on
 * the current colorspace and geometry. Keep this structure a multiple of
 * 16 in size.
 */
typedef struct DM_FrameBuffer_S { 
	unsigned short *bufP;
	unsigned short *pixelP;
	int paletteSize;
	int numPage;				// formerly the number of 8k pages. Now holds bytes.
	int horizPixel;
	int vertPixel;
	int extraLines;
	int reserved;
	UINT32 upperFrameDescPA;	// upper frame buffer descriptor physical address
	UINT32 upperFrameDescVA;	// upper frame buffer descriptor virtual address
	UINT32 lowerFrameDescPA;	// lower frame for the second LCD panel
	UINT32 lowerFrameDescVA;
} DM_FrameBuffer_T;


typedef struct LcdContextS *LcdContextPT;	// Need for dumb single-pass compiler.

/* Prototypes
 */

typedef void (*DM_Setup_T) (LcdContextPT contextP,
							int displayType, int colorSpace);

typedef void (*DM_On_T) (LcdContextPT contextP);

typedef void (*DM_Off_T) (LcdContextPT contextP);

typedef void (*DM_SetFrameBuffer_T) (LcdContextPT contextP,
									 DM_FrameBuffer_T * p);

typedef DM_FrameBuffer_T *(*DM_GetFrameBuffer_T) (LcdContextPT contextP);

typedef DM_FrameBuffer_T *(*DM_NewFrameBuffer_T) (LcdContextPT contextP);

typedef void (*DM_GetGeometry_T) (LcdContextPT contextP, int *h, int *v);

typedef int (*DM_GetColorSpace_T) (LcdContextPT contextP);

typedef int (*DM_GetColorDepth_T) (LcdContextPT contextP);

typedef int (*DM_GetDisplayFormat_T) (LcdContextPT contextP);

typedef void (*DM_GetOffsets_T) (LcdContextPT contextP,
								 int *hOffP, int *vOffP, int *fOffP);

/* Frame buffer display dirver interface
 */
typedef struct LcdContextS {
	void *regsP;
	DM_Setup_T setupFnP;
	DM_On_T onFnP;
	DM_Off_T offFnP;
	DM_SetFrameBuffer_T setFrameBufferFnP;
	DM_GetFrameBuffer_T getFrameBufferFnP;
	DM_NewFrameBuffer_T newFrameBufferFnP;
	DM_GetGeometry_T getGeometryFnP;
	DM_GetColorSpace_T getColorSpaceFnP;
	DM_GetColorDepth_T getColorDepthFnP;
	DM_GetDisplayFormat_T getDisplayFormatFnP;
	DM_GetOffsets_T getOffsetsFnP;
} LcdContextT;

LcdContextT *getLCDctx(void);

#endif							// #ifndef __LCDCONTROLLER_H__
